import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';

// 首页页面组件（有状态组件，用于轮播图等动态内容）
class WebViewPage extends StatefulWidget {
  final String title;
  const WebViewPage({super.key,required this.title});

  @override
  State<WebViewPage> createState() => _WebViewPageState();
}

class _WebViewPageState extends State<WebViewPage> {
  String? name;
  @override
  void initState() {
    super.initState();
    //组件初始化完成后获取路由参数
    WidgetsBinding.instance.addPostFrameCallback((timestamp){
      var map = ModalRoute.of(context)?.settings.arguments;
      if(map is Map){
        name = map["name"];
        setState(() {//为什么需要这个呢？需要重新渲染name

        });
      }
    });


  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title??""),),
      // 安全区域：避免内容被刘海屏/状态栏遮挡
      body: SafeArea(
        child: Container(
          child: InkWell(onTap: (){
            Navigator.pop(context);
          },
          child: Container(width: 200.w,height: 50.h,child: Text("返回"),),),
        ),
      ),
    );
  }
}
